package plantshop.tests;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import plantshop.model.CollisionDetector;
import plantshop.model.Customer;
import plantshop.model.Location;
import plantshop.model.Store;

public class CollisionDetectorTest
{
	Store store;
	Customer c1, c2, c3;
	
	@Before
	public void setUp() throws Exception
	{
		CollisionDetector.setStore(store = new Store(100, 1600.0/1920, 900.0/1080));
		CollisionDetector.setXScale(1600.0/1920);
		CollisionDetector.setYScale(900.0/1080);
		c1 = Customer.makeCustomer();
		store.sendCustomer(c1);
		c1.setLoc(new Location(1, 1));
		c2 = Customer.makeCustomer();
		store.sendCustomer(c2);
		c2.setLoc(store.getTopLeft());
		c3 = Customer.makeCustomer();
		store.sendCustomer(c3);
	}

	@After
	public void tearDown() throws Exception
	{
		c1 = null;
		c2 = null;
		c3 = null;
		store = null;
	}

	@Test
	public void testIsValid()
	{
		assertEquals(CollisionDetector.isValid(store.getTopLeft(), c1), 0);
		assertEquals(CollisionDetector.isValid(c2.getLoc(), c2), 1);
		assertEquals(CollisionDetector.isValid(store.getFront().get(0).getTopLeft(), c2), -1);
		assertEquals(CollisionDetector.isValid(new Location(1, 1), c3), -1);
		assertEquals(CollisionDetector.isValid(new Location(1920, 1080), c3), -1);
	}

}
